/*******************************************************************************
*  Project      : Minigate Golfin                                 
*  Program ID   : my_qna_write.js                            
*  Description  : 마이페이지 qna
*
********************************************************************************
*  Program History                                                            
*  Date        Author    Description                                          
*  ----------  --------  -------------------------------------------------------- 
*  2012-07-06  김효순    Created.  
*******************************************************************************/

jQuery(function($){
	// 질문구분
	function clsQnaType()
	{
		this._HTMLDom = null;
		this.radioValue = null;
		this.typeList = null;
		this.golfList = null;
		this._ERRMSG = {
			"NOVALUE_RADIO": "질문구분을 선택해 주십시요."
			, "NOVALUE_GROUP": "분류를 선택해 주십시요."
			, "NOVALUE_GOLF": "골프장을 선택해 주십시요."
		}
		this.errMsg = null;
		this.$errObj = null;
		
		this._init();
	}
	
	clsQnaType.prototype = {
		_init: function(){
			var $layer = $("div#container tr:eq(0)");
			this._HTMLDom = {
				"$layer": $layer
			}
			
			this.radioValue = ["S", "C"];
			this._setTypeList([
				{
					"대분류코드": ""
					, "대분류": "분류 선택"
				}
				, {
					"대분류코드": "B"
					, "대분류": "부킹"
				}
				, {
					"대분류코드": "C"
					, "대분류": "동호회"
				}
				, {
					"대분류코드": "J"
					, "대분류": "조인룸"
				}
				, {
					"대분류코드": "P"
					, "대분류": "결제"
				}
				, {
					"대분류코드": "M"
					, "대분류": "회원"
				}
				, {
					"대분류코드": "E"
					, "대분류": "기타"
				}
			]);
			
			this.$getHelpLayer().css({
				"left": "420px"
				, "right": ""
			}).hide();
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];
		}
		, $getHelpLayer: function(){
			return this.$getLayer().find("div.box_txt");
		}
		, getRadioValue: function(){
			var $layer = this._HTMLDom["$layer"];
			
			var n = $layer.find("input:radio").index($layer.find("input:radio:checked"));
			if(n < 0) return "";
			else return this.radioValue[n];
		}
		, setRadioValue: function(val){
			var $layer = this._HTMLDom["$layer"];
			
			var n = $.inArray(val, this.radioValue);
			$layer.find("input:radio").eq(n).attr("CHECKED", "CHECKED");
		}
		, _setTypeList: function(thisData){
			var $layer = this._HTMLDom["$layer"];
			var thisClass = this;

			this.typeList = thisData;
			
			$layer.find("select:eq(0)").empty();
			for(var i=0;i<this.typeList.length;i++){
				$layer.find("select:eq(0)").append("<option />");
			}
			$layer.find("select:eq(0) option").each(function(n){
				$(this).text(thisClass.typeList[n]["대분류"]);
			});
		}
		, setGolfList: function(thisData){
			var $layer = this._HTMLDom["$layer"];
			var thisClass = this;
			
			this.golfList = [{
				"골프장코드": ""
				, "골프장명": "골프장 선택"
			}].concat(thisData);
			
			$layer.find("select:eq(1)").empty();
			for(var i=0;i<this.golfList.length;i++){
				$layer.find("select:eq(1)").append("<option />");
			}
			$layer.find("select:eq(1) option").each(function(n){
				$(this).text(thisClass.golfList[n]["골프장명"]);
			});
		}, helpShow: function(){
			this.$getHelpLayer().show(300);
			
		}, helpHide: function(){
			this.$getHelpLayer().hide(300);
		}
		, getError: function(){
			if(this.errMsg) return this._ERRMSG[this.errMsg];
			else return null;
		}
		, focus: function(){
			var $layer = this._HTMLDom["$layer"];
			
			if(this.$errObj) this.$errObj.trigger("focus");
			else{
				$layer.find("input:radio:first").trigger("click");
			}
		}
		, valid: function(){
			var $layer = this._HTMLDom["$layer"];
			
			this.errMsg = null;
			this.$errObj = null;
			
			if(!this.getRadioValue()){
				this.errMsg = "NOVALUE_RADIO";
				this.$errObj = $layer.find("input:radio:first");
				return false;
			}else if(this.getRadioValue() == "S" && !this.getGroupValue()){
				this.errMsg = "NOVALUE_GROUP";
				this.$errObj = $layer.find("select:eq(0)");
				return false;
			}else if(this.getRadioValue() == "C" && !this.getGolfValue()){
				this.errMsg = "NOVALUE_GOLF";
				this.$errObj = $layer.find("select:eq(1)");
				return false;
			}
			
			return true;
		}
		, getRadioValue: function(){
			var $layer = this._HTMLDom["$layer"];
			var n = $layer.find("input:radio").index($layer.find("input:radio:checked"));
			
			if(n < 0) return "";
			else return this.radioValue[n];
		}
		, getGroupValue: function(){
			var $layer = this._HTMLDom["$layer"];
			var n = $layer.find("select:eq(0) option").index($layer.find("select:eq(0) option:selected"));
			
			return this.typeList[n]["대분류코드"];
		}
		, setGroupValue: function(val){
			var $layer = this._HTMLDom["$layer"];
			
			for(var i=0;i<this.typeList.length;i++){
				if(this.typeList[i]["대분류코드"] == val) break;
			}
			
			if(i<this.typeList.length){
				$layer.find("select:eq(0) option").eq(i).attr("SELECTED", "SELECTED");
			}
		}
		, getGolfValue: function(){
			var $layer = this._HTMLDom["$layer"];
			var n = $layer.find("select:eq(1) option").index($layer.find("select:eq(1) option:selected"));
			
			return this.golfList[n]["골프장코드"];
		}
		, setGolfValue: function(val){
			var $layer = this._HTMLDom["$layer"];
			
			for(var i=0;i<this.golfList.length;i++){
				if(this.golfList[i]["골프장코드"] == val) break;
			}
			
			if(i<this.typeList.length){
				$layer.find("select:eq(1) option").eq(i).attr("SELECTED", "SELECTED");
			}
		}
		, getDetailValue: function(){
			switch(this.getRadioValue()){
				case "S":
					return this.getGroupValue();
					break;
				case "C":
					return this.getGolfValue();
					break;
			}
		}
		, setDetailValue: function(val){
			switch(this.getRadioValue()){
				case "S":
					this.setGroupValue(val);
					break;
				case "C":
					this.setGolfValue(val);
					break;
			}
		}
		, setRadioN: function(n){
			this._HTMLDom["$layer"].find("input:radio").eq(n).trigger("click");
		}
	}
	
	// 제목
	function clsTitle()
	{
		this._HTMLDom = null;
		this._ERRMSG = {
			"NOVALUE": "제목을 입력해 주십시요."
			, "_MAXLENTH": "한글 30자 이내로 입력해 주십시요."
		}
		this.errMsg = null;
		
		this._init();
	}
	
	clsTitle.prototype = {
		_init: function(){
			var $layer = $("div#container tr:eq(1)");
			this._HTMLDom = {
				"$layer": $layer
			}
		}
		, getError: clsQnaType.prototype.getError
		, focus: function(){
			this._HTMLDom["$layer"].find("input:text").trigger("focus");
		}
		, valid: function(){
			this.errMsg = null;
			
			if(!this.getValue()){
				this.errMsg = "NOVALUE";
				return false;
			}else if(_util.getByteLen(this.getValue()) > 60){
				this.errMsg = "_MAXLENTH";
				return false;
			}
			
			return true;
		}
		, getValue: function(){
			return this._HTMLDom["$layer"].find("input:text").val();
		}
		, setValue: function(val){
			 this._HTMLDom["$layer"].find("input:text").val(val);
		}
	}
	
	// 휴대번호
	function clsPhone()
	{
		this._HTMLDom = null;
		this._ERRMSG = {
			"NOVALUE": "휴대번호를 입력해 주십시요."
		}
		this.errMsg = null;
		this.$errObj = null;
		
		this._init();
	}
	
	clsPhone.prototype = {
		_init: function(){
			var $layer = $("div#container tr:eq(2)");
			this._HTMLDom = {
				"$layer": $layer
			}
			
			$layer.find("input:text:eq(0)").attr("maxlength", "3");
			$layer.find("input:text:eq(1)").attr("maxlength", "4");
			$layer.find("input:text:eq(2)").attr("maxlength", "4");
		}
		, $getLayer: clsQnaType.prototype.$getLayer
		, getError: clsQnaType.prototype.getError
		, focus: function(){
			if(!this.$errObj) this.$errObj = this._HTMLDom["$layer"].find("input:text:first");
			clsQnaType.prototype.focus.apply(this, arguments);
		}
		, valid: function(){
			var $layer = this._HTMLDom["$layer"];
			
			this.errMsg = null;
			this.$errObj = null;
			
			for(var i=0;i<$layer.find("input:text").length;i++){
				if(!this.getValue(i)){
					this.errMsg = "NOVALUE";
					this.$errObj = $layer.find("input:text").eq(i);
					return false;
				}
			}
			
			return true;
		}
		, getValue: function(n){
			var $layer = this._HTMLDom["$layer"];
			var szRet = "";
			
			if(n == 0 || n){
				szRet = $layer.find("input:text").eq(n).val();
			}else{
				$layer.find("input:text").each(function(){
					if(szRet) szRet += "-";
					szRet += $(this).val();
				});
			}
			
			return szRet;
		}
		, setValue: function(val){
			var $layer = this._HTMLDom["$layer"];
			var a = _util.nvl(val).split("-");
			
			$layer.find("input:text").each(function(n){
				$(this).val(a[n]);
			});
		}
	}
	
	// 이메일
	function clsEmail()
	{
		this._HTMLDom = null;
		this._listData = null;
		
		this._ERRMSG = {
			"NOVALUE": "이메일을 입력해주세요."
			, "INVALID": "정상적인 이메일주소가 아닙니다."
		}
		this.errMsg = null;
		this.$errObj = null;
		
		this._init();
	}
	
	clsEmail.prototype = {
		_init: function(){
			var $layer = $("div#container tr:eq(3)");
			this._HTMLDom = {
				"$layer": $layer
			}
			
			this._setList([
				{
					"이메일": ""
					, "텍스트": "직접입력"
				}
				, {
					"이메일": "hanmail.net"
					, "텍스트": "다음"
				}
				, {
					"이메일": "naver.com"
					, "텍스트": "네이버"
				}
				, {
					"이메일": "nate.com"
					, "텍스트": "네이트"
				}
				, {
					"이메일": "dreamwiz.com"
					, "텍스트": "드림위즈"
				}
			]);
		}
		, _setList: function(thisData){
			var $layer = this._HTMLDom["$layer"];
			var thisClass = this;

			this._listData = thisData;
			
			$layer.find("select").empty();
			for(var i=0;i<this._listData.length;i++){
				$layer.find("select").append("<option />");
			}
			$layer.find("option").each(function(n){
				$(this).text(thisClass._listData[n]["텍스트"]);
			});
		}
		, $getLayer: clsQnaType.prototype.$getLayer
		, getError: clsQnaType.prototype.getError
		, valid: function(){
			var $layer = this._HTMLDom["$layer"];
			var regs = {
				"reg0":  /^[\w\-\.]+$/ig
				, "reg1": /^(?:(?:[\w\-]+\.)+[a-zA-Z]{2,})$/ig
			}
			
			this.errMsg = null;
			this.$errObj = null;
			
			for(var i=0;i<$layer.find("input:text").length;i++){
				if(!this.getValue(i)){
					this.errMsg = "NOVALUE";
					this.$errObj = $layer.find("input:text").eq(i);
					return false;
				}else if(!regs["reg" + i].test(this.getValue(i))){
					this.errMsg = "INVALID";
					this.$errObj = $layer.find("input:text").eq(i);
					return false;
				}
			}
			
			return true;
		}
		, getValue: function(n){
			var $layer = this._HTMLDom["$layer"];
			var szRet = "";
			
			if(n == 0 || n){
				szRet = $layer.find("input:text").eq(n).val();
			}else{
				$layer.find("input:text").each(function(){
					if(szRet) szRet += "@";
					szRet += $(this).val();
				});
			}
			
			return szRet;
		}
		, focus: clsPhone.prototype.focus
		, selectEmail: function(){
			var $layer = this._HTMLDom["$layer"];
			var n = $layer.find("option").index($layer.find("option:selected"));
			$layer.find("input:text:eq(1)").val(this._listData[n]["이메일"]);
			
			if(n == 0) $layer.find("input:text:eq(1)").trigger("focus");
		}
		, setValue: function(val){
			var $layer = this._HTMLDom["$layer"];
			var a = val.split("@");
			
			$layer.find("input:text").each(function(n){
				$(this).val(a[n]);
			});
		}
	}
	
	// 파일첨부
	function clsAttach()
	{
		this._HTMLDom = null;
		this.infoData = null;
		
		this._init();
	}
	
	clsAttach.prototype = {
		_init: function(){
			var $layer = $("div#container tr:eq(4)");
			this._HTMLDom = {
				"$layer": $layer
			}
			
			$layer.find("input:text").attr("READONLY", "READONLY");
			
			this.setInfo({});
		}
		, $getLayer: clsQnaType.prototype.$getLayer
		, setInfo: function(thisData){
			this.infoData = thisData;
			this.display();
		}
		, getInfo: function(){
			return this.infoData;
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("input:text").val(this.infoData["원본파일명"]);
			
		}
		, setAttach: function(callback){
			var $i = this.$getLayer().find("img[alt='파일첨부']:eq(1)");
			var p = $i.position();
			
			_gf.setUploadFileImage($i, null, function(ret){
				callback.apply(null, arguments);
			}, {
				"left": p["left"]
				, "top": p["top"] + 5
			});
		}
		, getValue: function(){
			var szRet = "";
			
			if(this.infoData && this.infoData["파일명"]){
				szRet = _util.nvl(this.infoData["파일코드"], "_NOT");
				szRet += ",_NOT," + this.infoData["파일명"] + "," + this.infoData["원본파일명"]
			}
			
			return szRet;
		}
	}
	
	// 상세내용
	function clsNote()
	{
		this._HTMLDom = null;
		this._ERRMSG = {
			"NOVALUE": "내용을 입력해 주십시요."
		}
		this.errMsg = null;
		
		this._init();
	}
	
	clsNote.prototype = {
		_init: function(){
			var $layer = $("div#container tr:eq(5)");
			this._HTMLDom = {
				"$layer": $layer
			}
		}
		, getError: clsQnaType.prototype.getError
		, focus: function(){
			this._HTMLDom["$layer"].find("textarea").trigger("focus");
		}
		, valid: function(){
			this.errMsg = null;
			
			if(!this.getValue()){
				this.errMsg = "NOVALUE";
				return false;
			}
			
			return true;
		}
		, getValue: function(){
			return this._HTMLDom["$layer"].find("textarea").val();
		}
		, setValue: function(val){
			this._HTMLDom["$layer"].find("textarea").val(val);
		}
	}
	
	
	
	// 서버통신
	function clsComm()
	{
		
		this._init();
	}
	
	clsComm.prototype = {
		_init: function(){
			
		}
		// 골프장 리스트
		, getGolfList: function(){
			var thisClass = this;
			
			//ajax
			var serviceName = "getGolfclubList";
			var options = {
				
			}
			_gf.ajax({
				"sid": "QA001"
				, "servicename": serviceName
			}, options, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": _gf.getResultMsg(ret)
				}
				
				var list = [];
				var items = ret["msp"]["contents"]["items"];
				if(items){
					if(!items.length) items = new Array(items);
					for(var i=0;i<items.length;i++){
						var obj = items[i];
						list.push({
							"골프장코드": _util.nvl(obj["golfclubId"])
							, "골프장명": _util.nvl(obj["golfclubName"])
							, "지역코드": _util.nvl(obj["region"])
						});
					}
				}
				res["리스트"] = list;
				document.objControl.finishGolfList(res);
			});
		}
		, submit: function(arg){
			var thisClass = this;
			
			//ajax
			var serviceName = "regQna";
			if(arg["질문코드"]) serviceName = "updateQna";
			var options = {
				"qna_seq": arg["질문코드"]
				, "qna_type": arg["질문구분"]
				, "qna_detail_type": arg["질문소분류"]
				, "phone": arg["휴대폰"]
				, "email": arg["이메일"]
				, "title": _util.ajaxTrans(arg["제목"])
				, "contents": encodeURIComponent(arg["내용"])
				, "file_list": arg["파일리스트"]
			}
			_gf.ajax({
				"sid": "QA001"
				, "servicename": serviceName
			}, options, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": _gf.getResultMsg(ret)
				}
				document.objControl.finishSubmit(res);
			});
		}
		, getContents: function(arg){
			var thisClass = this;
			
			//ajax
			var serviceName = "getDetailQna";
			var options = {
				"qna_seq": arg["질문코드"]
				, "modpage_yn": "Y"
			}
			_gf.ajax({
				"sid": "QA001"
				, "servicename": serviceName
			}, options, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": _gf.getResultMsg(ret)
					, "결과값": {}
				}
				
				var items = ret["msp"]["contents"]["items"];
				if(items){
					var obj = items;
					var fileList = {};
					
					if(obj["FileBean"]){
						var f = obj["FileBean"][0]["items"];
						
						fileList = {
							"파일코드": f["file__seq"]
							, "섬네일": "_NOT"
							, "파일명": f["path"] + f["save__file__name"]
							, "원본파일명": f["orgn__file__name"]
						}
					}
					
					
					res["결과값"] = {
						"질문코드": _util.nvl(obj["qna__seq"])
						, "대분류코드": _util.nvl(obj["qna__type"])
						, "소분류코드": _util.nvl(obj["qna__detail__type"])
						, "제목": _util.nvl(obj["title"])
						, "휴대폰": _util.nvl(obj["phone"])
						, "이메일": _util.nvl(obj["email"])
						, "내용": _util.nvl(obj["contents"])
						, "파일리스트": fileList
					}
				}
				
				document.objControl.finishContents(res);
			});
		}
	}
	
	// 컨트롤
	function clsControl()
	{
		this.objComm = null;
		this.objQnaType = null;
		this.objTitle = null;
		this.objPhone = null;
		this.objEmail = null;
		this.objAttach = null;
		this.objNote = null;
		
		this.q_seq = null;
		this.q_page = null;
		
		this._permitStart = null;
	}
	
	clsControl.prototype = {
		_init: function(){
			this._preload();
			
			this.objComm = new clsComm();
			this.objQnaType = new clsQnaType();
			this.objTitle = new clsTitle();
			this.objPhone = new clsPhone();
			this.objEmail = new clsEmail();
			this.objAttach = new clsAttach();
			this.objNote = new clsNote();
			
			this._beforeStart();
			this._bind();
			
		}
		, _preload: function(){
			_gf.spinStart();
			
		}
		, _beforeStart: function(){
			var thisClass = this;
			
			this._permitStart = {
				"골프장": false
			}
			
			this.q_seq = _util.getParam("q_seq");
			this.q_page = _util.getParam("q_page");
			
			
			$.ajax({
				url: _ROOT + "/js/mypage_common.js"
				, dataType: "script"
				, async: false
				, success: function(){
					
				}
				, error: function(){
					alert("error");
				}
			});
			
			// 골프장 리스트
			this.objComm.getGolfList();
			
			_util.executeThread(function(){
				for(key in thisClass._permitStart){
					if(!thisClass._permitStart[key]) return false;
				}
				
				return (_gf.getMyInfoData());
			}, function(){
				_gf.spinEnd();
				thisClass._start();
			});
		}
		, _bind: function(){
			var thisClass = this;
			
			// 확인
			$("div#container").on("click", "img[alt='등록']", function(){
				if(!thisClass.objQnaType.valid()){
					alert(thisClass.objQnaType.getError());
					thisClass.objQnaType.focus();
					return;
				}else if(!thisClass.objTitle.valid()){
					alert(thisClass.objTitle.getError());
					thisClass.objTitle.focus();
					return;
				}else if(!thisClass.objPhone.valid()){
					alert(thisClass.objPhone.getError());
					thisClass.objPhone.focus();
					return;
				}else if(!thisClass.objEmail.valid()){
					alert(thisClass.objEmail.getError());
					thisClass.objEmail.focus();
					return;
				}else if(!thisClass.objNote.valid()){
					alert(thisClass.objNote.getError());
					thisClass.objNote.focus();
					return;
				}
				
				_gf.spinStart("sending...");
				
				thisClass.objComm.submit({
					"질문코드": thisClass.q_seq
					, "질문구분": thisClass.objQnaType.getRadioValue()
					, "질문소분류": thisClass.objQnaType.getDetailValue()
					, "휴대폰": thisClass.objPhone.getValue()
					, "이메일": thisClass.objEmail.getValue()
					, "제목": thisClass.objTitle.getValue()
					, "내용": thisClass.objNote.getValue()
					, "파일리스트": thisClass.objAttach.getValue()
				});
			// 취소
			}).on("click", "img[alt='취소']", function(){
				thisClass.goBack();
			});
			
			// 이용문의
			this.objQnaType.$getLayer().on("hover", "img[alt='이용문의']", function(e){
				e = e || event;
				
				switch(e.type.toUpperCase()){
					case "MOUSEENTER":
						thisClass.objQnaType.helpShow();
						break;
					case "MOUSELEAVE":
						thisClass.objQnaType.helpHide();
						break;
				}
			});
			
			// 휴대폰 번호 숫자만입력
			this.objPhone.$getLayer().on("keyup change", "input:text", function(){
				var thisVal = $(this).val();
				var reVal = thisVal.replace(/\D/g, "");
				
				if(thisVal != reVal) $(this).val(reVal);
			});
			
			// 이메일 선택
			this.objEmail.$getLayer().on("change", "select", function(){
				thisClass.objEmail.selectEmail();
			});
			
			// 파일첨부
			thisClass.objAttach.setAttach(function(ret){
				if(ret["결과코드"] != "00000"){
					alert("파일업로드 오류발생!!");
					return;
				}
				
				var fs = ret["파일리스트"][0]["파일크기"]-0;
			
				if(fs >= 3 * 1024 * 1024){
					alert("사진용량은 3MB까지만 등록 가능합니다. 파일 용량을 확인하여 주세요.");
					return;
				}
				
				var fileList = ret["파일리스트"][0];
				
				thisClass.objAttach.setInfo(fileList);
			});
			
			// FAQ보기
			$(document).on("click", "img[alt='FAQ 보기']", function(){
				thisClass.goFAQPage();
			});
		}
		, _start: function(){
			if(this.q_seq){
				this.objComm.getContents({
					"질문코드": this.q_seq
				});
			}else{
				var m = _gf.getMyInfoData();
				
				this.objPhone.setValue(m["휴대폰"]);
				this.objEmail.setValue(m["이메일"]);
			}
		}
		// 골프장 리스트 완료
		, finishGolfList: function(ret){
			if(ret["메시지"]) alert(ret["메시지"]);
			if(ret["결과코드"] != "00000") return;
			
			this.objQnaType.setGolfList(ret["리스트"]);
			
			this._permitStart["골프장"] = true;
		}
		// 저장완료
		, finishSubmit: function(ret){
			if(ret["메시지"]) alert(ret["메시지"]);
			if(ret["결과코드"] != "00000") return;
			
			this.goList();
		}
		// 내용 완료
		, finishContents: function(ret){
			if(ret["메시지"]) alert(ret["메시지"]);
			if(ret["결과코드"] != "00000") return;
			
			var thisData = ret["결과값"];
			
			this.objQnaType.setRadioValue(thisData["대분류코드"]);
			this.objQnaType.setDetailValue(thisData["소분류코드"]);
			this.objTitle.setValue(thisData["제목"]);
			this.objPhone.setValue(thisData["휴대폰"]);
			this.objEmail.setValue(thisData["이메일"]);
			this.objAttach.setInfo(thisData["파일리스트"]);
			this.objNote.setValue(thisData["내용"]);
		}
		, goList: function(){
			document.location.href = _ROOT + "/mypage/my_qna_list.html";
		}
		, goBack: function(){
			if(this.q_seq){
				document.location.href = _ROOT + "/mypage/my_qna_view.html" + document.location.search;
			}else{
				document.location.href = _ROOT + "/mypage/my_qna_list.html?q_page=" + this.q_page;
			}
		}
		// FAQ 페이지
		, goFAQPage: function(){
			var szLink = _ROOT + "/launge/customer.html";
			
			$("body").append("<a href='" + szLink + "' id='idPermissionLink' />");
			$("a:last").get(0).click().end().remove();
		}
	}
	
	document.objControl = new clsControl();
	document.objControl._init();
});
